{template "common/header"}
<style type="text/css">
    .col-sm-2{
        width:11%;
    }
    .xh-toast-block{ min-width: 300px; position:fixed; z-index: 9999; font-size: 18px; color: #e7e7e7; padding: 10px 20px; background: rgba(0,0,0,0.7); left: 50%; top: 50%; line-height: 40px; border-radius: 10px; text-align: center; margin-top: -30px; margin-left: -150px; }
    .modeladd li{
        padding-top: 5px;
        padding-bottom: 5px;
        list-style: none;
        width: 100%;
        float: left;
    }
</style>
<ul class="nav nav-tabs">
    <li {if $op == 'payment'}class="active"{/if}>
    <a href="{php echo $this->createWebUrl('payment',array('op'=>'payment'))}" >订单信息</a>
    </li>
    <li {if $op == 'group'}class="active"{/if}>
    <a href="{php echo $this->createWebUrl('payment',array('op'=>'group'))}" >拼团信息</a>
    </li>
</ul>
{if $op == 'payment'}
<div style="margin-bottom: 25px">
    <div class="list-group">
        <div style="background-color: #D9EDF7;height: 48px;line-height: 48px">
            <p  style="background-color: #D9EDF7;float:left;border:none;padding: 0 15px;">
                按条件搜索
            </p>

        </div>
        <div active="list-group-item" style="border:1px solid #D9EDF7;height: 150px;">
            <form action="./index.php" method="get" id="search" class="form-horizontal">
                <input type="hidden" name="c" value="site">
                <input type="hidden" name="a" value="entry">
                <input type="hidden" name="m" value="goouc_class">
                <input type="hidden" name="do" value="payment">

                <div class="form-group col-sm-2" style="margin-top:25px;width:220px;" >
                    <label  class="col-sm-6 control-label" >订单类型：</label>
                    <select class="col-sm-6" name="type" >
                        <option  value="3" {if $type == 3}selected = "selected"{/if} class="form-control" >不限</option>
                        <option  value="1" {if $type == 1}selected = "selected"{/if} class="form-control" >原价</option>
                        <option  value="2" {if $type == 2}selected = "selected"{/if} class="form-control" >团购</option>
                    </select>
                </div>
                <div class="form-group col-sm-2" style="margin-top:25px;width:220px;" >
                    <label  class="col-sm-6 control-label">支付状态：</label>
                    <select class="col-sm-6" name="order_status" >
                        <option  value="3" {if $order_status == 3}selected = "selected"{/if} class="form-control" >不限</option>
                        <option  value="1" {if $order_status == 1}selected = "selected"{/if} class="form-control" >已完成</option>
                        <option  value="2" {if $order_status == 2}selected = "selected"{/if} class="form-control" >未完成</option>
                    </select>
                </div>
                <div class="form-group col-sm-2" style="margin-top:25px;width:260px;">
                    <label  class="col-sm-6 control-label">拼团状态：</label>
                    <select class="col-sm-6" name="group_status" >
                        <option  value="3" {if $group_status == 3}selected = "selected"{/if} class="form-control" >不限</option>
                        <option  value="1" {if $group_status == 1}selected = "selected"{/if} class="form-control" >拼团中</option>
                        <option  value="2" {if $group_status == 2}selected = "selected"{/if} class="form-control" >拼团失败</option>
                        <option  value="2" {if $group_status == 4}selected = "selected"{/if} class="form-control" >拼团成功</option>
                    </select>
                </div>
                <div class="form-group col-sm-2" style="margin-top:25px;width:350px;" >
                    <label class=" control-label" style="display: inline-block;vertical-align: middle;margin-left: 20px;margin-top: -7px;">订单时间：</label>
                    <div class="" style="display: inline-block;vertical-align: middle;">
                        {php echo tpl_form_field_daterange('time',array('starttime'=>($starttime ? date('Y-m-d ',$starttime):false),'endtime'=>($endtime?date('Y-m-d ',$endtime):false)))}
                    </div>
                </div>
                <div class="form-group col-sm-2" style="margin-top:25px;width:220px;" >

                    <button class="btn btn-default" style="" form="search"><i class="fa fa-search"></i> 搜索</button>
                </div>
                <div style="clear:both"></div>
            </form>
        </div>
    </div>
</div>
<div style="margin-bottom: 25px">
    <div class="list-group">
        <div style="background-color: #D9EDF7;height: 48px;line-height: 48px">
            <p style="background-color: #D9EDF7;float:left;border:none;padding: 0 15px;">订单统计，当前总收益 <span style="color:red">{$money}元</span></p>
            <a href="{php echo $this->createWebUrl('payment',['op'=>'download','type'=>$type,'order_status'=>$order_status,'group_status'=>$group_status,'time'=>array('starttime'=>($starttime ? date('Y-m-d ',$starttime):false),'endtime'=>($endtime?date('Y-m-d ',$endtime):false))])}" class="btn btn-success form-group"   style="float:right;margin-right: 15px;margin-bottom: 0px;margin-top: 9px">导出</a>
        </div>
        <div active="list-group-item" style="border:1px solid #D9EDF7;margin-bottom: 15px">
            <table class="table table-bordered table-hover" style="margin-top:25px;width:98%" align="center">
                <thead >
                <tr >
                    <th>购买者</th>
                    <th>头像</th>
                    <th>手机号</th>
                    <th style="width:25%">购买课程</th>
                    <th>开课时间</th>
                    <!--<th>节课时间</th>-->
                    <th>课次</th>
                    <th style="width:8%">购买类型</th>
                    <th>下单时间</th>
                    <th>支付时间</th>
                    <th>拼团状态</th>
                    <th>退款状态</th>

                </tr>
                {loop $list $row}
                <tr>
                    <td>{$row['nickname']}</td>
                    <td><img src="{php echo $row['headimg'];}" alt="" style="width: 25px"></td>
                    <td>{$row['phone']}</td>
                    <td>{$row['title']}</td>
                    <td>{php echo date('Y/m/d H:i:s',$row['starttime'])}</td>
                    <!--<td>结课时间</td>-->
                    <td>{$row['sonnum']}</td>
                    <td>{if $row['type'] == 1}原价购买{elseif $row['type'] == 2 || $row['type'] == 3}团购{elseif $row['type'] == 4}兑换币购买{/if}</td>
                    <td>{php echo date('Y/m/d H:i:s',$row['createtime'])}</td>
                    <td>{if empty($row['paytime'])}未支付{else}{php echo date('Y/m/d H:i:s',$row['paytime'])}{/if}</td>
                    <td>
                        {if $row['type'] == 2 || $row['type'] == 3}
                        {$row['groupstatus']}
                        {else}

                        {/if}
                    </td>
                    <td>
                        {if $row['groupstatus'] == '拼团失败' }
                        {$row['refund_status']}
                        {else}

                        {/if}
                    </td>
                </tr>
                {/loop}
                </thead>
            </table>
        </div>
        {$page}
    </div>
</div>
<script>
    /*$('#download').click(function () {
        //获取当前的搜索条件
        var data = {};
        data.type = $('select[name="type"] :selected').val();
        data.order_status = $('select[name="order_status"] :selected').val();
        data.group_status = $('select[name="group_status"] :selected').val();
        data.starttime = $('input[name="time[start]"]').val();
        data.endtime = $('input[name="time[end]"]').val();
        console.log(data);
        //导出当前搜索的记录
        $.ajax({
            type:'post',
            url:"{php echo $this->createWebUrl('payment',['op'=>'download'])}",
            data:data,
            success:function(res){
                console.log(res);
            }
        })
    });*/
</script>
{elseif $op == 'group'}
<div class="list-group">
    <!--<p class="list-group-item" style="background-color: #D9EDF7;position: relative;">已过期的拼团</p>
    <div active="list-group-item" style="border:1px solid #cecece">

    </div>-->
    <div style="margin-top: 25px">
        <div class="list-group">
            <p  class="list-group-item " style="background-color: #D9EDF7" >团购列表</p>
            <div active="list-group-item" style="border:1px solid #cecece;margin-bottom: 15px">
                <table class="table table-hover table-bordered" style="margin-top:25px;width:98%" align="center">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th style="width:10%">建团时间</th>
                        <th>参团人数</th>
                        <th>团长昵称</th>
                        <th>团长头像</th>
                        <th>拼团课程</th>
                        <th>团状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {loop $list $row}
                    <tr>
                        <td>{php echo 1;}</td>
                        <td>{php echo date("Y/m/d H:i:s",$row['createtime'])}</td>
                        <td>{$row['groupnum']}</td>
                        <td>{$row['nickname']}</td>
                        <td><img src="{$row['headerimg']}" alt="" width="40px"></td>
                        <td>
                            {$row['title']}
                        </td>
                        <td {if time() > ($row['createtime'] + 3600*$config['validtime']) && $row['status'] == 2}style="color:red"{/if}>
                            {if $row['status'] == 1}
                                已完成
                            {else}
                                {if time() > ($row['createtime'] + 3600*$config['validtime'])}
                                    {if $row['status'] == 2}
                                        已过期(未退费)
                                    {elseif $row['status'] == 3}
                                        已过期(已退费)
                                    {/if}
                                {else}
                                    进行中
                                {/if}
                            {/if}
                        </td>

                        <td>
                            {if $row['status'] == 1}
                                已完成
                            {else}
                                {if time() > ($row['createtime'] + 3600*$config['validtime'])}
                                    {if $row['status'] == 2}
                                        <!--<button class="btn btn-danger" onclick="tui({$row['id']});">退款</button>-->
                                        <button class="btn btn-danger" >退款</button>
                                    {elseif $row['status'] == 3}
                                        已过期(已退费)
                                    {/if}
                                {else}
                                    进行中
                                {/if}
                            {/if}
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
            {$page}
        </div>
    </div>
</div>
<script>
    function tui(groupid) {
        $.ajax({
            url:"{php echo $this->createWebUrl('payment',array('op'=>'refund'))}",
            type:'post',
            data:{groupid:groupid},
            success:function(res){
                console.log(res);
                var res = JSON.parse(res);
                if(res.success == 200){
                    xhToast(res.msg);
                    windows.location.reload();
                }
            }
        });
    }
    function xhToast(_text){
        $('body').append("<div class='xh-toast-block'>"+_text+"</div>");
        setTimeout(function(){
            $('.xh-toast-block').remove();
        },2000);
    }
</script>
{/if}


{template "common/footer"}